<style>
.view-key {
	width:135px;
	float:left;
	text-align:right;
}
.view-value {
	margin-left:145px;
}
</style>

<p>
<a href="/admin/users/edit/{{$model_item['id']}}" class="btn btn-primary">编辑用户资料</a>


{{if Configure::read('Easemob.open') == 1}}
	<button onclick="ajaxAction('/admin/users/setEasemodPwd/{{$model_item['id']}}');" class="btn btn-primary" >重置环信密码</button>
{{/if}}
</p>


<div class="ui-portlet clearfix">
	<div class="ui-portlet-header">
		<span class="title">用户资料</span>            
	</div>
	<div class="ui-portlet-content">
		<div style="clear:both;">
			<div class="view-key"><B>用户编号:</B></div>
			<div class="view-value">
				{{$model_item['id']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>用户名:</B></div>
			<div class="view-value">
				{{$model_item['username']}}
			</div>
		</div>

		<div style="clear:both;">
			<div class="view-key"><B>手机号:</B></div>
			<div class="view-value">
				{{$model_item['mobile']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>邮箱:</B></div>
			<div class="view-value">
				{{$model_item['email']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>上次登录时间:</B></div>
			<div class="view-value">
				{{$model_item['last_login']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>积分:</B></div>
			<div class="view-value">
				{{$model_item['score']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>注册时间:</B></div>
			<div class="view-value">
				{{$model_item['created']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>用户状态:</B></div>
			<div class="view-value">
				{{$model_item['status']}}
			</div>
		</div>
		<div style="clear:both;">
			<div class="view-key"><B>邀请码:</B></div>
			<div class="view-value">
				{{$model_item['invite_code']}}
			</div>
		</div>
	</div>
</div>

{{if !empty($datainfo['Role']) }}
<div class="ui-portlet-header">
	<span class="title">用户角色</span> <small style="font-size:12px;">(过期不显示)</small>            
</div>
<table class="table table-bordered">
   	<thead><tr><th>角色编号</th><th>角色名称</th><th>开始时间</th><th>结束时间</th><th>剩余天数</th><th>操作</th></tr></thead>   
{{loop $datainfo['Role'] $role}}
	<tr><td>{{$role['id']}}</td><td>{{$role['name']}}</td><td>{{$role['UserRole']['started']}}</td><td>{{$role['UserRole']['ended']}}</td>
	<td>
	{{if strtotime($role['UserRole']['ended']) > time() }}
		{{ intval( (strtotime($role['UserRole']['ended'])-time())/86400 ) }}
	{{else}}
		0
	{{/if}}
	</td><td><a target="_blank" href="/admin/user_roles/edit/{{$role['UserRole']['id']}}">修改过期时间</a></td></tr>
{{/loop}}
</table>
{{/if}}

{{if !empty($datainfo['Oauthbind']) }}

<div class="ui-portlet-header">
	<span class="title">第三方账号授权</span>            
</div>
<table class="table table-bordered">
   	<thead><tr><th>授权编号</th><th>授权来源</th><th>用户名称</th><th>授权时间</th><th>Openid</th><th>token</th><th>slug</th></tr></thead>   
{{loop $datainfo['Oauthbind'] $oauth}}
	<tr><td>{{$oauth['id']}}</td><td>{{$oauth['source']}}</td><td>{{$oauth['oauth_name']}}</td><td>{{$oauth['created']}}</td><td>{{$oauth['oauth_openid']}}</td><td>{{$oauth['oauth_token']}}</td><td>{{$oauth['domain']}}</td></tr>
{{/loop}}
</table>

{{/if}}

{{if !empty($datainfo['Company']) }}
<div class="ui-portlet-header">
	<span class="title">用户公司</span>            
</div>
<table class="table table-bordered">
   	<thead><tr><th>公司编号</th><th>公司名称</th><th>状态</th><th>角色编号</th><th>加入时间</th><th>操作</th></tr></thead>
   
{{loop $datainfo['Company'] $comp}}
	<tr><td>{{$comp['id']}}</td><td>{{$comp['name']}}</td><td>{{$comp['CompanyMember']['status']}}</td><td>{{$comp['CompanyMember']['role_id']}}</td><td>{{$comp['CompanyMember']['created']}}</td>
	<td><a title="删除后，可刷新查看" class="showtooltip" onclick="if(confirm('确认操作')) ajaxAction(this.href);return false;" href="/admin/company_members/delete/{{$comp['CompanyMember']['id']}}">从公司中移除</a></td></tr>
{{/loop}}
</table>

{{/if}}

<portlet cache="no" return="array" return_var="paylogs" model="PayLog" limit="100" fields="PayLog.*" order="id desc" info="conditions[user_id]=$id">
</portlet>
<?php
$paylogs =  $paylogs['datalist'];
 ?>

{{if $paylogs}}
<div class="ui-portlet-header">
	<span class="title">订单支付记录</span>
</div>
<table class="table table-bordered">
	<thead><tr><th>支付记录编号</th><th>支付方式</th><th>银行</th><th>用户编号</th><th>币种</th><th>支付时间</th><th>支付金额</th><th>支付交易号</th><th>订单编号</th><th>查看订单</th></tr></thead>
	{{loop $paylogs $log}}
		<?php $item = $log['PayLog']; ?>
	<tr><td>{{$item['id']}}</td><td>{{$item['pay_method']}}</td><td>{{$item['bank_type']}}</td><td>{{$item['user_id']}}</td><td>{{$item['fee_type']}}</td><td>{{$item['created']}}</td><td>{{$item['total_fee']}}</td><td>{{$item['transaction_id']}}</td><td>{{$item['order_id']}}</td><td><a target="_blank" href="/admin/orders/view/{{$item['order_id']}}">查看订单</a></td></tr>
	{{/loop}}
</table>
{{/if}}

<?php
$settings = json_decode($datainfo['UserSetting']['settings'],true);
?>
{{if !empty( $settings ) }}
<div class="ui-portlet-header">
	<span class="title">用户参数设置</span>            
</div>
<?php echo array_to_table($settings); ?>

{{/if}}